package com.sg.service.biz.bff.impl;

import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.bff.req.BffAddStandardDetermineTenantCertificateAvailabilityAbnormalComReqDto;
import com.sg.dto.biz.bff.req.BffJudgeDetermineTenantKeyAvailabilityReqDto;
import com.sg.dto.biz.bff.res.BffAddStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto;
import com.sg.dto.biz.bff.res.BffJudgeDetermineTenantKeyAvailabilityRespDto;
import com.sg.dto.integration.app.JudgeDetermineTenantKeyAvailabilityReqDto;
import com.sg.dto.integration.app.JudgeDetermineTenantKeyAvailabilityRespDto;
import com.sg.dto.integration.app.JudgeStandardDetermineTenantCertificateAvailabilityAbnormalComReqDto;
import com.sg.dto.integration.app.JudgeStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto;
import com.sg.service.biz.bff.SecurityService;
import com.wicket.okrapp.integration.SecurityService;
import com.sg.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class SecurityServiceImpl implements SecurityService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    com.sg.service.biz.app.SecurityService fwAppSecurityClient;

    /**
     * B3新增通用租户规划证书及异常(公共)[6601]
     * gen by moon at 5/13/2023, 5:23:28 AM
     */
    @Trace(operationName = "B3新增通用租户规划证书及异常(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto addStandardDetermineTenantCertificateAvailabilityAbnormalCom(BffAddStandardDetermineTenantCertificateAvailabilityAbnormalComReqDto reqDto) {


        JudgeStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto judgeStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto_1 = null;
//步骤0: D3判断通用租户规划证书及异常(公共) - judgeStandardDetermineTenantCertificateAvailabilityAbnormalCom
        JudgeStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto judgeStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto = null;
        JudgeStandardDetermineTenantCertificateAvailabilityAbnormalComReqDto judgeStandardDetermineTenantCertificateAvailabilityAbnormalComReqDto = new JudgeStandardDetermineTenantCertificateAvailabilityAbnormalComReqDto();
        if (reqDto != null) {
            judgeStandardDetermineTenantCertificateAvailabilityAbnormalComReqDto.setAuthorizationKeyTypeCode(reqDto.getAuthorizationKeyTypeCode());//SimpleFieldAssign//sourceId:932201_1
            judgeStandardDetermineTenantCertificateAvailabilityAbnormalComReqDto.setTenantSpaceId(reqDto.getTenantSpaceId());//SimpleFieldAssign//sourceId:927501_1
        }

        /*D3判断通用租户规划证书及异常(公共)[6600]   */
        Assert.isNull(judgeStandardDetermineTenantCertificateAvailabilityAbnormalComReqDto.getAuthorizationKeyTypeCode(), "B3新增通用租户规划证书及异常(公共)-D3判断通用租户规划证书及异常(公共)-开通钥匙类型标识不能为空", false);
        Assert.isNull(judgeStandardDetermineTenantCertificateAvailabilityAbnormalComReqDto.getTenantSpaceId(), "B3新增通用租户规划证书及异常(公共)-D3判断通用租户规划证书及异常(公共)-租户空间ID不能为空", false);
        judgeStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto = fwAppSecurityClient.judgeStandardDetermineTenantCertificateAvailabilityAbnormalCom(judgeStandardDetermineTenantCertificateAvailabilityAbnormalComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        judgeStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto_1 = judgeStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto;

        BffAddStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto retData = new BffAddStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto();
        if (judgeStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto_1 != null) {
            retData.setKeyOperateType(judgeStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto_1.getKeyOperateType());//SimpleFieldAssign//sourceId:927496_1
            retData.setServiceAbnormalWords(judgeStandardDetermineTenantCertificateAvailabilityAbnormalComRespDto_1.getServiceAbnormalWords());//SimpleFieldAssign//sourceId:927497_1
        }


        return retData;
    }

    /**
     * B3判断租户规划钥匙可用(管理)[6538]
     * gen by moon at 5/25/2023, 5:07:29 PM
     */
    @Trace(operationName = "B3判断租户规划钥匙可用(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffJudgeDetermineTenantKeyAvailabilityRespDto judgeDetermineTenantKeyAvailability(BffJudgeDetermineTenantKeyAvailabilityReqDto reqDto) {


        JudgeDetermineTenantKeyAvailabilityRespDto judgeDetermineTenantKeyAvailabilityRespDto_1 = null;
//步骤0: D3判断租户规划钥匙可用 - judgeDetermineTenantKeyAvailability
        JudgeDetermineTenantKeyAvailabilityRespDto judgeDetermineTenantKeyAvailabilityRespDto = null;
        JudgeDetermineTenantKeyAvailabilityReqDto judgeDetermineTenantKeyAvailabilityReqDto = new JudgeDetermineTenantKeyAvailabilityReqDto();
        if (reqDto != null) {
            judgeDetermineTenantKeyAvailabilityReqDto.setPrivacyCode(reqDto.getPrivacyCode());//SimpleFieldAssign//sourceId:911986_1
            judgeDetermineTenantKeyAvailabilityReqDto.setAuthorizationKeyTypeCode(reqDto.getAuthorizationKeyTypeCode());//SimpleFieldAssign//sourceId:932186_1
        }

        /*D3判断租户规划钥匙可用[6536]   */
        Assert.isNull(judgeDetermineTenantKeyAvailabilityReqDto.getPrivacyCode(), "B3判断租户规划钥匙可用(管理)-D3判断租户规划钥匙可用-权限标识不能为空", false);
        Assert.isNull(judgeDetermineTenantKeyAvailabilityReqDto.getAuthorizationKeyTypeCode(), "B3判断租户规划钥匙可用(管理)-D3判断租户规划钥匙可用-开通钥匙类型标识不能为空", false);
        judgeDetermineTenantKeyAvailabilityRespDto = fwAppSecurityClient.judgeDetermineTenantKeyAvailability(judgeDetermineTenantKeyAvailabilityReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        judgeDetermineTenantKeyAvailabilityRespDto_1 = judgeDetermineTenantKeyAvailabilityRespDto;

        BffJudgeDetermineTenantKeyAvailabilityRespDto retData = new BffJudgeDetermineTenantKeyAvailabilityRespDto();
        if (judgeDetermineTenantKeyAvailabilityRespDto_1 != null) {
            retData.setIsHaveDisplayPower(judgeDetermineTenantKeyAvailabilityRespDto_1.getIsHaveDisplayPower());//SimpleFieldAssign//sourceId:911994_1
            retData.setKeyOperateType(judgeDetermineTenantKeyAvailabilityRespDto_1.getKeyOperateType());//SimpleFieldAssign//sourceId:911995_1
            retData.setServiceAbnormalWords(judgeDetermineTenantKeyAvailabilityRespDto_1.getServiceAbnormalWords());//SimpleFieldAssign//sourceId:911996_1
        }


        return retData;
    }
    //
}
